package com.dabai.linktools;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.dabai.linktools.activitys.LinkCollectionActivity;
import com.dabai.linktools.databinding.ActivityMainBinding;
import com.dabai.linktools.utils.DabaiUtils;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding amb;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        amb = ActivityMainBinding.inflate(LayoutInflater.from(this));
        setContentView(amb.getRoot());


        amb.textView4.setText("下载位置 : " + getExternalFilesDir(null));

    }

    public void help_1(View view) {
        new DabaiUtils().openLink(this, "https://dabai2017.gitee.io/help/LinkTools/netease.html");
    }

    public void help_2(View view) {
        new DabaiUtils().openLink(this, "https://dabai2017.gitee.io/help/LinkTools/bili.html");
    }


    //菜单
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.feedback:
                new DabaiUtils().openLink(this, "https://support.qq.com/products/140224");
                break;
            case R.id.zan:
                new DabaiUtils().openLink(this, "market://details?id=" + getPackageName());
                break;
        }
        return super.onOptionsItemSelected(item);
    }


    public void toCollection(View view) {
        startActivity(new Intent(this, LinkCollectionActivity.class));
    }

    public void help_3(View view) {
        new DabaiUtils().openLink(this, "https://dabai2017.gitee.io/help/LinkTools/collection.html");
    }
}